import ConfigParser
import Util
import pygame
import sys
import os, os.path
import G

configdir = 'Config'
leveldir = 'Levels'

autosaveloc = 'Autosave.save'

windows = sys.platform[:3].lower() == 'win'
mac = sys.platform[:6].lower() == 'darwin'

moneytoscore = 1000

aimdict = {'aim_normal': 0,
           'aim_at': 1,
           'aim_lead': 2}
homedict = {'dumb': 0,
            'home': 1,
            'smart_home': 2}
ammodropthresholds = [0.9,0.7,0.4]
ammodropchances = [0.2,0.2,0.2]
ammorefills = ['25 Ammo Refill', '50 Ammo Refill', '100 Ammo Refill']
            
def load_config(configurable):
   truename = os.path.join(os.curdir, configdir, '%ss.config' 
      % configurable.__name__)
   return configurable.many_from_file(truename)

cf  =  ConfigParser.RawConfigParser()
cf.read(os.path.join(os.curdir, configdir, 'Config.config'))

section = 'General'

def get(option):
   return Util.str_convert(cf.get(section, option))

frame_rate = get('frame_rate')
width = get('width')
height = get('height')
screen_expand_dist = get('screen_expand_dist')
scroll_rate = get('scroll_rate')
actioncheckinterval = get('actioncheckinterval')
HUDinterval = 3
repairdropinterval = get('repairdropinterval')
if windows:
   default_font = 'lucidaconsole'
   default_font_size = 24
elif mac:
   default_font = 'couriernew'
   default_font_size = 24
else:
   default_font = 'liberationmono'
   default_font_size = 24

section = 'Collisions'

collide_hurts = get('collide_hurts')
bulk_mult = get('bulk_mult')
damage_to_impulse = get('damage_to_impulse')
player_ship_rect_contract = 3

section = 'Navigation'

reachedradius = get('reachedradius')

section = 'AI'

target_check_interval = get('target_check_interval')

section = 'Projectiles'

max_projectile_gap = get('max_projectile_gap')
hitscan_trail_lifetime = get('hitscan_trail_lifetime')

section = 'Explosions'

explosion_outer_damage_mult = get('explosion_outer_damage_mult')
explosion_mid = get('explosion_mid')
explosion_mid_damage_mult = get('explosion_mid_damage_mult')
explosion_inner = get('explosion_inner')
explosion_lifetime = get('explosion_lifetime')
death_explosion_proportion = get('death_explosion_proportion')
death_explosion_power = get('death_explosion_power')
explode_damage_thresholds = get('explode_damage_thresholds')
explode_temperature_thresholds = get('explode_temperature_thresholds')
explosioncolors = get('explosioncolors')
friendly_explosion_damage = get('friendly_explosion_damage')
praxiseffect = False

section = 'Graphics'

targetingreticle = get('targetingreticle')
lockedreticle = get('lockedreticle')

multiplayer = False
nova = False

import Weapon
import Shield
import Generator
import Powerup
import Ship
weapons = load_config(Weapon.Weapon)
for w in weapons.keys():
   G.items[w] = weapons[w]
shields = load_config(Shield.Shield)
for s in shields.keys():
   G.items[s] = shields[s]
generators = load_config(Generator.Generator)
for g in generators.keys():
   G.items[g] = generators[g]
G.powerup_dict = load_config(Powerup.Powerup)
G.ships = load_config(Ship.Ship)
